//
// Created by dgy on 2022/12/12.
//
#include "iostream"
using namespace std;
#include "vector"
vector<int> getLeastNumbers(vector<int>& arr,int k){
    int a[10002]={0};
    vector<int> dest;
    if (k==0)
        return dest;
    for (int i = 0; i <arr.size() ; ++i) {
        a[arr[i]]+=1;
    }
    for (int j = 0; j < 10002; ++j) {
        if (a[j]!=0){
            if (k<=a[j]){
                for (int i = 0; i <k; ++i) {
                    dest.push_back(j);
                }
                return dest;
            }else{
                for (int i = 0; i < a[j]; ++i) {
                    dest.push_back(j);
                    k--;
                }
            }
        }
    }
}